/*
 * @Author: your name
 * @Date: 2020-08-23 19:50:48
 * @LastEditTime: 2020-08-23 20:50:26
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \新建文件夹\two-app\src\utils\filterRoutes.js
 */
// 筛选路由权限
export const filterRoutes = (AllRoutes, userInfo) => {
  const res = AllRoutes.filter(item => {
    return item.meta.author.indexOf(userInfo) !== -1
  })
  res.length > 0 && res.forEach(item => {
    // 判断是否有二级路由
    if (item.children) {
      // 吧item.children ---给赋值成功我这个身份能够访问的二级路由
      item.children = filterRoutes(item.children, userInfo)
    }
  })
  // 返回筛选后的数组
  return res
}
